this._selected = false;
},
+ get slot() {
+ let x, y, w, h;
+
+ if (this.inDrag) {
+ x = this.dragOrigX;
+ y = this.dragOrigY;
+ w = this.actor.width * this.dragOrigScale;
+ h = this.actor.height * this.dragOrigScale;
+ } else {
+ x = this.actor.x;
+ y = this.actor.y;
+ w = this.actor.width * this.actor.scale_x;
+ h = this.actor.height * this.actor.scale_y;
+ }
+
+ return [x, y, w, h];
+ },
+
setStackAbove: function (actor) {
this._stackAbove = actor;
if (this.inDrag || this._zooming)
this._updateCaptionId = metaWindow.connect('notify::title',
Lang.bind(this, function(w) {
this.title.text = w.title;
+ // we need this for the next call to get_preferred_width
+ // to return useful results
+ this.title.set_size(-1, -1);
+
+ this._repositionSelf();
}));
let button = new St.Button({ style_class: 'window-close' });
this.title.height + this.title._spacing];
},
+ _repositionSelf: function() {
+ let [cloneX, cloneY, cloneWidth, cloneHeight] = this._windowClone.slot;
+ this.updatePositions(cloneX, cloneY, cloneWidth, cloneHeight, false);
+ },
+
/**
* @cloneX: x position of windowClone
* @cloneY: y position of windowClone
else
button.set_position(Math.floor(buttonX), Math.floor(buttonY));
- if (!title.fullWidth)
- title.fullWidth = title.width;
- let titleWidth = Math.min(title.fullWidth, cloneWidth);
+ let [titleMinWidth, titleNatWidth] = title.get_preferred_width(-1);
+ let titleWidth = Math.max(titleMinWidth, Math.min(titleNatWidth, cloneWidth));
let titleX = cloneX + (cloneWidth - titleWidth) / 2;
let titleY = cloneY + cloneHeight + title._spacing;
--- /dev/null
+#!/usr/bin/env gjs
+
+const Gtk = imports.gi.Gtk;
+const Mainloop = imports.mainloop;
+
+function nextTitle() {
+ let length = Math.random() * 20;
+ let str = '';
+
+ for (let i = 0; i < length; i++) {
+ // 97 == 'a'
+ str += String.fromCharCode(97 + Math.random() * 26);
+ }
+
+ return str;
+}
+
+function main() {
+ Gtk.init(null);
+
+ let win = new Gtk.Window({ title: nextTitle() });
+ win.connect('destroy', Gtk.main_quit);
+ win.present();
+
+ Mainloop.timeout_add(5000, function() {
+ win.title = nextTitle();
+ return true;
+ });
+
+ Gtk.main();
+}
+
+main();
+